In this part of the course, we will cover the following concepts:
plotly expressplotly expressCheck out this interactive graphic from The Guardian about dog breeds and how they are related to each other
What surprised you?
What did you already know?
| Objective | Complete |
|---|---|
| Define Plotly Express | |
| Describe univariate plots in Plotly Express |
plotly?Plotly is a powerful graphing library that is used to create interactive, publication-quality graphs
In plotly, you can create line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts, and bubble charts
Click here for more about plotly
plotly express?plotly express contains functions that can create entire figures at onceplotly express or PXplotly express is a built-in part of the plotly library which is the recommended for creating most common figuresplotly express we can create a majority of the most commonly-used interactive visualizations in data science with single line of codeplotly express, you can make professional interactive visualizations easily and quickly| Objective | Complete |
|---|---|
| Define Plotly Express |
✔ |
| Describe univariate plots in Plotly Express |
# Load the libraries and the dataset
import plotly.express as px
# Load the dataset
tips_dataset = px.data.tips()
# Top 5 entires of the dataset
tips_dataset.head() total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4
plotly expressA univariate plot shows the ins and outs of a single variable
There are different type of univariate plots available in plotly express:
We will talk about a subset of these univarite plots
plotly express allows us to create layered histograms, where layers can be toggledplotly express also has built-in datasets for use with plotting tools, which we will be using in next slides to create visualizationWhile that is a gorgeous plot, we might want to make some changes to make it look more professional
Let’s create the plot to measure bill on a daily basis and add the labels, the color scheme and the number of bins
Try the following:
plotly colors to build histogramsplotly, click hereWith interactive box plots, each box plot can be toggled on or off, so all our variables can be visible at once
We can choose to set the toggle using the color attribute
In this case, we set the color attribute to day column so we can toggle to analyze the total bill across various days
marginal to create small box plot above the main histogram
| Objective | Complete |
|---|---|
| Define Plotly Express |
✔ |
| Describe univariate plots in Plotly Express |
✔ |
You are now ready to try Tasks 1-3 in the Exercise for this topic